package ro.ubbcluj.cs.damate.plugin.settings;

import org.eclipse.jface.preference.IPreferenceStore;

import ro.ubbcluj.cs.damate.plugin.DamateActivator;

public class DamateSettings {

	public static final String CAPTURE_ENABLED_KEY = DamateActivator.PLUGIN_ID + ".enabled"; 
	
	public boolean isEnabled() {
		if (System.getProperties().containsKey(CAPTURE_ENABLED_KEY)) {
			return "true".equals(System.getProperty(CAPTURE_ENABLED_KEY));
		} else if (getPreferencesStore().contains(CAPTURE_ENABLED_KEY)) {
			return getPreferencesStore().getBoolean(CAPTURE_ENABLED_KEY);
		} else {
			return true;
		}
	}

	public void setEnabled(boolean value) {
		if (getPreferencesStore().getBoolean(CAPTURE_ENABLED_KEY) == value) {
			return;		
		}
		getPreferencesStore().setValue(CAPTURE_ENABLED_KEY, value);
	}
	
	private IPreferenceStore getPreferencesStore() {
		return DamateActivator.getDefault().getPreferenceStore();
	}
}
